package ar.uba.tleng.g99.expregs.parser;

import java.util.Set;

import ar.uba.tleng.g99.expregs.automata.AutomataND;

public final class AtomExpr implements Expr {

	private final char c;
	
	public AtomExpr(char c) {
		this.c = c;
	}
	
	@Override
	public AutomataND automata(Set<Character> sigma) {
		return AutomataND.simpleTransition(sigma, this.c);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + c;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AtomExpr other = (AtomExpr) obj;
		if (c != other.c)
			return false;
		return true;
	}

	@Override
	public String toString() {
		if (c != 0) {
			return "AtomExpr [c=" + c + "]";
		} else {
			return "AtomExpr [c=lambda]";
		}
	}

}
